﻿@{
    ViewBag.Title = "CustomerOrderDetailList";
}

<div class="center">
        <div id="Breadcrumb" class="Breadcrumb">
        <ul>
            <li class="first">
                <a href='javascript:;' onclick="javascript:loadAction('Index2','Main')">
                    Trang chủ
                </a>
            </li>
            <li>
                <a href='javascript:;' onclick="javascript:loadAction('personal','Account')">
                    Tài khoản của tôi
                </a>
            </li>            
            <li>
                @{var level = new int[] { 0, 1 };}
                @if(Session["userLevel"] != null && level.Contains((int)Session["userLevel"]))
                {
                    <a href='javascript:;' onclick="javascript:loadAction('adminOrderList','Admin')">
                    Danh sách đơn hàng
                    </a>      
                }else{
                <a href='javascript:;' onclick="javascript:loadActionData('CustomerOrderList','Account','accID=@Session["accID"]')">
                    Danh sách đơn hàng
                </a>  
                }              
            </li>
            <li>
                <span>Danh sách chi tiết sản phẩm</span>
            </li>
        </ul>
    </div>
    <div class="Account-Module DefaultModule">
    
<div class="Block DefaultModule">
    

    <div id="CartHeader" class="Block Moveable Panel">
        <h2>
            Danh sách chi tiết sản phẩm
        </h2>
    </div>

    <div id="CartContainer" class="Block Moveable Panel">

        <div class="BlockContent">
            @if(Session["userLevel"] != null && level.Contains((int)Session["userLevel"]))
                {
            <div class="Clear">
                        <h3>
                            <span>Khách hàng: @ViewBag.order.Account.username</span>
                        </h3>
                    </div>
            }
            @if (ViewBag.orderDetailList != null)
            {                
                <form action="/Account/CustomerOrderDetailListClick" method="post">
                    <div>
                        <div>

                            <table class="CartContents" cellspacing="0" rules="rows" border="1" id="cphMain_ctl00_ctl01_ctl00_grvList" style="width: 100%; border-collapse: collapse;">
                                <tbody>
                                    <tr>
                                        <th align="left" scope="col">Sản phẩm
                                        </th>
                                        <th>
                                            Hình ảnh
                                        </th>
                                        <th scope="col">Số lượng
                                        </th>
                                        <th align="right" scope="col">Giá
                                        </th>
                                        <th align="right" scope="col">Tổng
                                        </th>
                                        <th scope="col">&nbsp;</th>
                                    </tr>

                                    @foreach (var od in ViewBag.orderDetailList)
                                    {
                                        <tr>
                                            <td align="left">
                                                <a href="javascript:;" onclick="javascript:viewProduct(@od.product_ID)">
                                                    <strong>@od.Product.name</strong></a>
                                                <div style="font-style: italic;"></div>
                                                <br>                                                
                                                <span class="hidden">0</span>
                                            </td>
                                            <td align="center">
                                                <a href="javascript:;" onclick="javascript:viewProduct(@od.product_ID)">
                                                    <img src="/Content/data/images/350.300/@od.Product.image_link" height="100"/>
                                                </a>
                                            </td>
                                            <td align="center" style="width: 70px;">
                                                @{var read = ""; 
                                                  if (ViewBag.order.status != "waiting" && !level.Contains((int)Session["userLevel"])) { read = "readonly"; }
                                                  var maxQuan = od.quantity + od.Product.capacity;
                                    }
                                                <input name="quantity @od.ID" type="number" value="@od.quantity" min="0" max="@maxQuan"
                                                    id="quantity @od.ID" @read class="NormalTextBox" 
                                                    onkeypress="javascript:return keypress(event);" style="width: 45px;">                                                
                                            </td>
                                            <td align="right" style="width: 80px;">                                                                                                
                                                <span>@od.price.ToString("0,0") VND / thùng</span>                                                
                                            </td>
                                            <td align="right" style="width: 90px;">                                                
                                                <b>@od.total.ToString("0,0") VND</b>
                                            </td>
                                            <td align="center" style="width: 1px;">
                                                @if (ViewBag.order.status == "waiting" || level.Contains((int)Session["userLevel"]))
                                                {
                                                <a href="javascript:;" onclick="javascript:removeOrderDetail(@od.Order.customer_ID,@od.order_ID,@od.ID)" class="remove-item myBtn1">Xóa</a>
                                                }
                                            </td>
                                        </tr>
                                    }
                                    <tr>
                                        <td align="right" colspan="4">
                                            <div class="SubTotal">
                                                Thành tiền:
                                            </div>

                                            <div class="SubTotal">
                                                Thuế (10%):
                                            </div>                                            
                                            <div class="SubTotal">
                                                Tổng tiền thanh toán:
                                            </div>
                                        </td>
                                        <td align="right">
                                            <div>
                                                <em class="ProductPrice">@ViewBag.order.subtotal.ToString("0,0") VND</em>
                                            </div>
                                            
                                            <div>
                                                <em id="promotionPrice" class="ProductPrice">@ViewBag.order.tax.ToString("0,0") VND</em>
                                            </div>               
                                                                 
                                            <div>
                                                <em id="grandTotal" class="ProductPrice">@ViewBag.order.total.ToString("0,0") VND</em>
                                            </div>
                                        </td>
                                        <td>&nbsp;</td>
                                    </tr>
                                </tbody>
                            </table>

                        </div>

                    </div>

                    <div class="Clear">
                        @if (ViewBag.order.status == "waiting" || level.Contains((int)Session["userLevel"]))
                        {
                        <div class="FloatRight">
                            <input type="hidden" value="@ViewBag.order.ID" name="hiddenOrderID"/>
                            <input type="submit" name="btnSubmit" value="Cập nhật số lượng" id="Action">
                            <a class="myBtn1" href="javascript:;" onclick="javascript:removeOrder(@Session["accID"],@ViewBag.order.ID)">Xóa đơn hàng</a>
                            <a class="myBtn1" href="javascript:;" onclick="javascript:AddCartToOrder(@ViewBag.order.ID)">Thêm sản phẩm từ giỏ hàng</a>                            
                        </div>
                        }
                    </div>

                    <div class="Clear">
                    </div>
                </form>
            }
            
        </div>
    </div>        
</div>


</div>

</div>
